package com.training.collections.set;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.TreeSet;

import com.training.collections.vo.Employee;
import com.training.collections.vo.NameComparator;

public class EmployeeSet {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Employee employee0 = new Employee("Naresh", "10");
		employee0.setJoiningDate(new Date(2004, 3, 12));
		Employee employee1 = new Employee("Alex", "10");
		employee0.setJoiningDate(new Date(2004, 3, 12));
		Employee employee2 = new Employee("Kalyan", "10");
		Employee employee3 = new Employee("Varshith", "13");
		Employee employee10 = new Employee("Naresh", "13");
		Employee employee11 = new Employee("Alex", "11");
		Employee employee12 = new Employee("Kalyan", "12");
		Employee employee13 = new Employee("Varshith", "13");

		ArrayList<Employee> arrayList = new ArrayList<Employee>();
		arrayList.add(employee0);
		arrayList.add(employee1);
		arrayList.add(employee2);
		arrayList.add(employee3);
		arrayList.add(employee10);
		arrayList.add(employee11);
		arrayList.add(employee12);
		arrayList.add(employee13);
		//arrayList.add("THIS is String");
		

		
		System.out.println("Before Sorting");

			
		
		
		
		for (Iterator iterator = arrayList.iterator(); iterator.hasNext();) {
			Employee employee = (Employee) iterator.next();

			if(employee.getName().equalsIgnoreCase("Naresh")){
			iterator.remove();
			}
			employee.display();

		}
		 
		Collections.sort(arrayList, new NameComparator());
		
		System.out.println("After Sorting");
		

		
		for (Iterator iterator = arrayList.iterator(); iterator.hasNext();) {
			Employee employee = (Employee) iterator.next();

			employee.display();

		}

		
		
 /*
		TreeSet employeeSet = new TreeSet();

		employeeSet.add(employee0);
		employeeSet.add(employee1);
		employeeSet.add(employee2);
		employeeSet.add(employee3);
		employeeSet.add(employee10);
		employeeSet.add(employee11);
		employeeSet.add(employee12);
		employeeSet.add(employee13);

		for (Iterator iterator = employeeSet.iterator(); iterator.hasNext();) {
			Employee employeeObj = (Employee) iterator.next();

			employeeObj.display();
		}
*/
	}

}
